<?php

include 'lib.php';
include 'config.php';
require_once 'lib/NewsRetriever.php';

/**
 * Duplicate of getNews.php until rule in .htaccess is defined.  
 */

// If the key is send via POST, use POST instead of GET.
if(isset($_POST['k'])){
    $_GET = $_POST;
}

$key = $_GET['k'];

if(!isValidApp($key)){
    logger("News", "INVALID_KEY", $key);
    header ("Content-Type:text/xml");
    echo '<?xml version="1.0"?><Status>INVALID_KEY</Status>';
    exit();
}

logger("News", "OK", $key);

$nr = new NewsRetriever();
$text = $nr->retrieve();

header ("Content-Type:text/xml");
echo utf8_encode($text);

?>
